//! 全功能节点
//!
//!

use crate::bean::node::base_node::BaseNode;
use std::ops::{Deref, DerefMut};

#[derive(Debug, Clone, Default)]
pub struct FullNode {
    base_node: BaseNode, // 节点的基本信息
    hash: String,        // 对应区块hash值（变更节点信息会更新）
}

impl FullNode {
    pub fn new(base_node: &BaseNode, hash: &str) -> Self {
        Self {
            base_node: base_node.clone(),
            hash: hash.to_string(),
        }
    }

    pub fn hash(&self) -> &str {
        &self.hash
    }

    pub fn base_node(&self) -> &BaseNode {
        &self.base_node
    }

    pub fn set_hash(&mut self, hash: &str) {
        self.hash = hash.to_string();
    }

    pub fn set_base_node(&mut self, base_node: &BaseNode) {
        self.base_node = base_node.clone();
    }
}

impl Deref for FullNode {
    type Target = BaseNode;

    fn deref(&self) -> &Self::Target {
        &self.base_node
    }
}

impl DerefMut for FullNode {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.base_node
    }
}
